package com.fang.six.srv.emun;

public enum  Gender implements GenderDesc {

    MALE("男"){
        // 匿名内部类，编译后该文件为：Gender$1.class，下同
        public void info() {
            System.out.println("这是一个定义性别的枚举类");
        }
    }, FEMALE("女"){
        public void info() {
            System.out.println("这是一个定义性别的枚举类");
        }
    };

    private String name;



    private Gender(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        switch (this) {
            case MALE:
                if ("男".equals(name)) {
                    this.name = name;
                } else {
                    System.out.println("参数错误");
                    return;
                }
                break;
            case FEMALE:
                if ("女".equals(name)) {
                    this.name = name;
                } else {
                    System.out.println("参数错误");
                    return;
                }
                break;
        }
        this.name = name;
    }
}
